<?php

namespace App\Http\Middleware;

use Closure;

class Token
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

    $api_token= md5('camelLongLive'.date('YmdH'));

    $token = $request->input('token');

    //exit;

      if ($token == $api_token) {
            return $next($request);
        }
        //重定向到控制器
        return redirect()->action('api\UserLoginController@loginFailure');
    }
}